const searchFormList = [
  { label: '关键词', value: 'query', type: 'input', width: '200px' },
  { label: '配置KEY', value: 'key', type: 'input', width: '200px' },
  { label: '', width: '200px', value: 'btn', type: 'slot' }
];

const tables = [ // 表格数据
  { label: '记录ID', value: 'id', width:100},
  { label: '配置名称', value: 'name', width:180},
  { label: '配置KEY', value: 'key', width:180},
  { label: '配置内容', value: 'value'},
  { label: '备注', value: 'memo', width:260},
  { label: '更新时间', value: 'stime', type: 'slot', width:120},
  { label: '操作', type: 'slot', value: 'btn',width:160}
];

const fieldList = [ // 新增弹出数据
  { label: '配置KEY', value: 'key', type: 'input', width: '300px'},
  { label: '配置名称', value: 'name', type: 'input', width: '300px'},
  { label: '配置内容', value: 'value', type:'textarea', width: '640px', autosize:{minRows: 18, maxRows: 1000}},
  { label: '备注', value: 'memo', type: 'textarea', width: '640px'},
];

const rules = {
  key: [{ required: true, message: '请输入配置KEY', trigger: 'change' }],
  value: [{ required: true, message: '请输入配置内容', trigger: 'change' }],
  name: [{ required: true, message: '请输入配置名称', trigger: 'change' }],
  memo: [{ required: true, message: '请输入配置备注', trigger: 'change' }]
};

const fieldData = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldList.length; idx++) {
    var ckey  = fieldList[idx].value;
    dataset[ckey] = (data)? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

export default {
  searchFormList,tables,fieldList,fieldData,rules
};
